import { Injectable } from '@nestjs/common';
import * as crypto from 'crypto';

@Injectable()
export class CryptoService {
  encrypt(data: string): string {
    const hmac = crypto.createHmac('sha256', 'mySecret');
    return hmac.update(data).digest('hex');
  }

  verity(data: string, hash: string): boolean {
    data = this.encrypt(data);
    return data === hash;
  }
}
